<?php

namespace app;

trait ContainerTrait
{
    protected static $container = [];

    public static function getInstance()
    {
        $class = static::class;
        if (!isset(self::$container[$class]) || !self::$container[$class] instanceof self) {
            self::$container[$class] = new static();
        }
        return self::$container[$class];
    }
}